/** @type {import('knex').Knex} */
exports.up = function(knex) {
  return knex.schema.raw(`
    CREATE VIEW n1790_view_rack_server_view AS
    SELECT 
      rs._id,
      rs.机柜ID,
      rs.资产ID,
      rs.起始U位,
      rs.设备大小,
      rs.服务器类型,
      rs.备注,
      rs.是否禁用,
      rs.是否删除,
      rs._create,
      rs._update,
      ri.机柜名称,
      zi.资产名称,
      zi.设备分类,
      zi.IP地址,
      zi.CPU,
      zi.内存,
      zi.硬盘,
      zi.设备状态,
      zi.网络状态,
      zi.丢包率
    FROM n1790_rack_server rs
    LEFT JOIN n1790_rack_info ri ON rs.机柜ID = ri._id
    LEFT JOIN n1790_r5xnmdhjm4_zichan_info zi ON rs.资产ID = zi._id
  `);
};

exports.down = function(knex) {
  return knex.schema.raw('DROP VIEW IF EXISTS n1790_view_rack_server_view');
}; 